<?php
    @header("Content-Type:text/html;charset=utf-8");

    // 1. 链接mysql
    const host = "localhost:3306";
    const user = "root";
    const pwd = "root";
    const dbName = "2108";

    // mysqli_connect(host,user,pwd)
    // 链接成功  => 链接对象
    // 链接失败  => Access denied for user 'root'@'localhost'

    $conn = mysqli_connect(host,user,pwd);

    // print_r($conn);

    // 2. 选择数据库
    // mysqli_select_db($conn,dbName);
    // $conn   mysql的链接对象
    // dbName  数据库名称

    // 返回值  选择成功 => true  失败=> false

    $res = mysqli_select_db($conn,dbName);

    // echo $res;

    if(!$res) {
        exit("数据库连接失败!!!");
    }






?>